package me.sapling.single;

import java.util.HashMap;
import java.util.Map;

/**
 * @author sapling
 */
public class VowelStatistics {

	private static String src;
	private static Map<Character, Integer> statistics;
	static {
		statistics = new HashMap<>();
		statistics.put('a', 0);
		statistics.put('e', 0);
		statistics.put('i', 0);
		statistics.put('o', 0);
		statistics.put('u', 0);
	}

	private static void mapInit() {
		statistics.replace('a', 0);
		statistics.replace('e', 0);
		statistics.replace('i', 0);
		statistics.replace('o', 0);
		statistics.replace('u', 0);
	}

	public static Map<Character, Integer> doWork(String src) {
		VowelStatistics.src = src;
		resolutionA();
		return statistics;
	}

	private static void resolutionA() {
		char[] chars = src.toLowerCase().toCharArray();
		for (char cha :
				chars) {
			switch (cha) {
				case 'a':
					statistics.replace('a', statistics.get('a')+1);
					break;
				case 'e':
					statistics.replace('e', statistics.get('e')+1);
					break;
				case 'i':
					statistics.replace('i', statistics.get('i')+1);
					break;
				case 'o':
					statistics.replace('o', statistics.get('o')+1);
					break;
				case 'u':
					statistics.replace('u', statistics.get('u')+1);
					break;
				default:
					break;
			}
		}
	}

}
